<template>
	<view class="topbar" :class="isFixed  && 'fixed'">
		<view class="left">
			<image src="@/static/img/topbar/back.svg" class="icon back-icon" v-if="isShowBack" @click="goBack" />
			<slot name="left">
			</slot>
		</view>
		<view class="center">
			<slot name="default">
				默认标题
			</slot>
		</view>
		<view class="right">
			<slot name="right">
				<!-- <image src="@/static/img/search.svg" class="icon search-icon" v-if="isShowSearch" /> -->
			</slot>
		</view>
	</view>
</template>

<script setup lang="ts">
	defineProps({
		// 是否显示返回按钮
		isShowBack: {
			type: Boolean,
			default: true
		},
		// 是否fixed
		isFixed: {
			type: Boolean,
			default: false
		}
	})
	// 返回上一页
	function goBack() {
		uni.navigateBack()
	}
</script>

<style scoped lang="scss">
	.topbar {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 108rpx 32rpx 24rpx;
		width: 100%;
		height: 176rpx;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 38rpx;
		background-color: #fff;
		box-sizing: border-box;

		&.fixed {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 9999;
		}

		.icon {
			width: 32rpx;
			height: 32rpx;
		}
	}
</style>